<?php
/**
 * パラメータからクエリを作成する。
 *
 * @author     NKGR.Inc
 * @version   $id:$   
 */
function parameter_to_query ($module_name, $action_name, $query_parameters = array()) {

    $route = $module_name."/".$action_name."/";
    $query = "";
    
    foreach ($query_parameters as $k => $v) {
        if (is_array($v) && count($v) > 0) {
            foreach ($v as $v2) {
                $query .= "&".$k . "=" . urlencode($v2);
            }
        } else {
            if ($v != '') {
                $query .= "&".$k . "=" . urlencode($v);
            }
        }
    }
    
    $query =  $query != '' ? $route."?".substr($query,1)."&" : $route."?";
    return $query;
}

function get_query ($query_parameters = array()) {

    foreach ($query_parameters as $k => $v) {
        if (is_array($v) && count($v) > 0) {
            foreach ($v as $v2) {
                $query .= "&".$k . "=" . urlencode($v2);
            }
        } else {
            if ($v != '') {
                $query .= "&".$k . "=" . urlencode($v);
            }
        }
    }
    
    $query =  $query != '' ? substr($query,1) : '';
    return $query;
}

?>